<template>
  <div class="pagePersonalCenter">
    <headerT title="历史爆款"  :isShowBack="false"/>
    <div class="pageNormalBackground headMarginTop pagesMain" ref="targetDiv">
      <div v-if="historyList.length==0" class="noData">-- 暂无数据 --</div>
      <div
        class="everyBlockBgcolor everyBlockPadding list"
        v-for="(item,index) in historyList"
        :key="index"
        @click="$tools.goPage_query('goodsDetails',{goods_id:item.id})"
      >
        <div class="list_img" v-if="item.good_img.length!=0">
          <img :src="item.good_img[0].img_url" />
          <div class="hot">热卖</div>
        </div>

        <div class="list_title">
          <div class="goodsTitle">
            <!-- <span class="isTag">结束</span> -->
            <span>{{item.goods_name}}</span>
          </div>
          <div class="goodsPrice">
            <span class="goodsNewPrice">
              {{item.good_marketing!=null&&item.good_marketing.pattern!=1?'￥'+item.good_marketing.promotion_price:(item.good_specification.length!=0?'￥'+item.good_specification[0].price:'')}}
              <!-- {{item.good_marketing!=null&&item.good_specification.length!=0?'￥'+item.good_specification[0].promotion_price:(item.good_marketing==null&&item.good_specification.length!=0?'￥'+item.good_specification[0].price:'')}} -->
            </span>
            <span
              class="goodsOldPrice"
            >{{item.good_marketing!=null&&item.good_specification.length!=0?'￥'+item.good_specification[0].price:''}}</span>
          </div>
          <img
            src="../../../static/images/sale.png"
            class="yiSale"
            v-if="item.good_specification.length!=0&&item.good_specification[0].inventory==0"
          />
        </div>
      </div>
    </div>
    <tabcard style="position: fixed;width: 100%;bottom:0;" />
  </div>
</template>

<script>
import headerT from "@/components/header";
import tabcard from "@/components/tabCard";
import { hotStyleHistoryList } from "@/services/historyHot";

export default {
  name: "login",
  components: {
    tabcard,
    headerT
  },

  data() {
    return {
      needInfo: {
        page: 1,
        pageSize: 10
      },
      totalPage: 0, //总页数
      historyList: [] //历史列表
    };
  },
  created() {
    this.getHotList();
  },
  mounted() {
    window.addEventListener("scroll", this.handleScroll);
  },
  methods: {
    handleScroll() {
      //分页加载数据
      if (
        document.documentElement.scrollTop + window.innerHeight >=
        document.body.offsetHeight
      ) {
        if (this.needInfo.page >= this.totalPage) {
          return;
        } else {
          this.needInfo.page = this.needInfo.page + 1;
          this.getHotList();
        }
      }
    },
    getHotList() {
      //历史爆款列表
      this.$vux.loading.show({
        text: "Loading"
      });
      this.$post(hotStyleHistoryList, this.needInfo)
        .then(res => {
          this.$vux.loading.hide();
          if (this.needInfo.page == 1) {
            this.historyList = res.data.data;
            this.needInfo.page = res.data.current_page;
            this.totalPage = res.data.last_page;
          } else {
            this.historyList = [...this.historyList, ...res.data.data];
          }
        })
        .catch(error => {
          this.$vux.loading.hide();
        });
    }
  }
};
</script>

<style lang="less" rel="stylesheet/less" type="text/css" scoped>
.pagePersonalCenter {
  .pagesMain {
    padding-bottom: 1.6rem;
  }

  .list {
    box-sizing: border-box;
    height: 3.18rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e6e6e6;
  }
  .list_img {
    width: 2.88rem;
    height: 2.44rem;
    text-align: center;
    position: relative;
  }
  .list_img img {
    width: 2.88rem;
    height: 2.44rem;
    display: block;
  }
  .hot {
    width: 2.88rem;
    height: 0.49rem;
    background: rgba(13, 13, 13, 0.23);
    line-height: 0.49rem;
    border-radius: 0.08rem;
    font-size: 0.25rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    text-align: center;
    position: absolute;
    bottom: 0rem;
    font-weight: 400;
  }

  .list_title {
    margin-left: 0.3rem;
    width: calc(100% - 3.26rem);
    height: 1.98rem;
    position: relative;
  }
  .isTag {
    background: #f64135;
    color: #ffffff;
    font-size: 0.2rem;
    padding: 0.06rem 0.12rem;
    border-radius: 0.08rem;
  }
  .goodsTitle {
    color: #4e4e4e;
    font-size: 0.34rem;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-all;
    height: 1.05rem;
  }
  .goodsPrice {
    margin-top: 0.45rem;
    line-height: 1.05rem;
  }
  .goodsNewPrice {
    color: #f64135;
    font-size: 0.44rem;
    font-weight: bold;
  }
  .goodsOldPrice {
    color: #9f9f9f;
    font-size: 0.25rem;
    text-decoration: line-through;
    margin-left: 0.12rem;
    font-weight: 400;
  }
  .list_title .yiSale {
    position: absolute;
    width: 1.77rem;
    height: 1.65rem;
    bottom: -0.2rem;
    right: 0.08rem;
  }
}
</style>
